﻿
window.onload = function() { 
rolinTab("rolin") 
} 
function rolinTab(obj) { 
var list = $(obj).getElementsByTagName("LI"); 
var state = {show:false,hidden:false,showObj:false}; 
for (var i=0; i<list.length; i++) { 
var tmp = new rolinItem(list[i],state); 
if (i == 0) tmp.pShow(); 
} 
} 
function rolinItem(obj,state) { 
var speed = 0.0666; 
var range = 1; 
var interval; 
var tarH; 
var tar = this; 
var head = getFirstChild(obj); 
var content = getNextChild(head); 
var isOpen = false; 
this.pHidden = function() { 
if (isOpen) hidden(); 
} 
this.pShow = show; 
var baseH = content.offsetHeight; 
content.style.display = "none"; 
var isOpen = false; 
head.onmouseover = function() { 
this.style.background = "#eaeaea"; 
} 
head.onmouseout = mouseout; 
head.onclick = function() { 
this.style.background = "#eaeaea"; 
if (!state.show && !state.hidden) { 
if (!isOpen) { 
document.getElementById("img1").src = 'img/biao10.png';
document.getElementById("img2").src = 'img/biao11.png';
document.getElementById("img3").src = 'img/01.png';
document.getElementById("img4").src = 'img/02.png';
document.getElementById("img5").src = 'img/biao12.png';
document.getElementById("img6").src = 'img/03.png';
document.getElementById("img7").src = 'img/06.png';
document.getElementById("img8").src = 'img/04.png';
document.getElementById("img9").src = 'img/biao13.png';
if(head.textContent=="值班管理")
{
document.getElementById("img1").src = 'img/liang01.png';
}
if(head.textContent=="运行监控")
{
document.getElementById("img2").src = 'img/liang02.png';
}
if(head.textContent == "定期维护")
{
document.getElementById("img3").src = 'img/liang03.png';
}
if(head.textContent == "故障检修")
{
document.getElementById("img4").src = 'img/liang04.png';
}
if(head.textContent == "设备履历")
{
document.getElementById("img5").src = 'img/liang05.png';
}
if(head.textContent == "人员资质")
{
document.getElementById("img6").src = 'img/liang06.png';
}
if(head.textContent == "资料管理")
{
document.getElementById("img7").src = 'img/liang07.png';
}
if(head.textContent == "人员培训考核管理")
{
document.getElementById("img8").src = 'img/liang08.png';
}
if(head.textContent == "系统管理")
{
document.getElementById("img9").src = 'img/liang09.png';
}
head.onmouseout = null; 
show(); 
} else { 
document.getElementById("img1").src = 'img/biao10.png';
document.getElementById("img2").src = 'img/biao11.png';
document.getElementById("img3").src = 'img/01.png';
document.getElementById("img4").src = 'img/02.png';
document.getElementById("img5").src = 'img/biao12.png';
document.getElementById("img6").src = 'img/03.png';
document.getElementById("img7").src = 'img/06.png';
document.getElementById("img8").src = 'img/04.png';
document.getElementById("img9").src = 'img/biao13.png';
hidden(); 
} 
} 
} 
function mouseout() { 
this.style.background = "#eaeaea" 
} 
function show() { 
head.style.borderBottom = "0px solid #dad9d9"; 
state.show = true; 
if (state.openObj && state.openObj != tar ) { 
state.openObj.pHidden(); 
} 
content.style.height = "0px"; 
content.style.display = "block"; 
content.style.overflow = "hidden"; 
state.openObj = tar; 
tarH = baseH; 
interval = setInterval(move,10); 
} 
function showS() { 
isOpen = true; 
state.show = false; 
} 
function hidden() { 
state.hidden = true; 
tarH = 0; 
interval = setInterval(move,10); 
} 
function hiddenS() { 
head.style.borderBottom = "none"; 
head.onmouseout = mouseout; 
head.onmouseout(); 
content.style.display = "none"; 
isOpen = false; 
state.hidden = false; 
} 
function move() { 
var dist = (tarH - content.style.height.pxToNum())*speed; 
if (Math.abs(dist) < 1) dist = dist > 0 ? 1: -1; 
content.style.height = (content.style.height.pxToNum() + dist) + "px"; 
if (Math.abs(content.style.height.pxToNum() - tarH) <= range ) { 
clearInterval(interval); 
content.style.height = tarH + "px"; 
if (tarH != 0) { 
showS() 
} else { 
hiddenS(); 
} 
} 
} 
} 
var $ = function($) {return document.getElementById($)}; 
String.prototype.pxToNum = function() {return Number(this.replace("px",""))} 
function getFirstChild(obj) { 
var result = obj.firstChild; 
while (!result.tagName) { 
result = result.nextSibling; 
} 
return result; 
} 
function getNextChild(obj) { 
var result = obj.nextSibling; 
while (!result.tagName) { 
result = result.nextSibling; 
} 
return result; 
} 
